package zjut.raymond.witdemo.pf;

import java.util.ArrayList;
import java.util.List;

import zjut.raymond.witdemo.pojo.LocationResult;

public class ParticleFilter {
    /**
     * 粒子数
     */
    private static final int N = 100;
    /**
     * 粒子存活数
     */
    private int survivorNum;

    /**
     * 粒子初始化采样 噪声：均值为0，方差为1m ,根据地图信息转换为36像素点
     */
    private int noise = 36;

    /**
     * 存储粒子的链表
     */
    private List<Particle> particleList = new ArrayList<>();

    interface LocationInterface {
        void onStepChanged(double stepLength, double orientation);

        void onWifiLocationChanged(LocationResult location);
    }

    public LocationInterface locationInterface;

//    /**
//     * 粒子失效数目
//     */
//    private int deadNum;

    public ParticleFilter(LocationResult location) {
        for (int i = 0; i < N; i++) {
            int randX = (int) (Math.random() * 72 - 36);
            int randY = (int) (Math.random() * 72 - 36);
            particleList.add(new Particle(location.getX() + randX, location.getY() + randY, 1 / N));
        }
        survivorNum = N;
    }

    public void setLocationInterface(LocationInterface locationInterface) {
        this.locationInterface = locationInterface;
    }

    /**
     * 根据步长和航向进行状态转移
     * @param stepLength
     * @param orientation
     */
    public void onStepChanged(double stepLength, double orientation) {

    }
}
